# routers/participant.py
import logging
from fastapi import APIRouter, Depends
from schema_base import PageInationResult
from http_base import unified_resp
from ..schemas.participant import (
    ParticipantListIn, ParticipantDetailIn, ParticipantAddIn, ParticipantEditIn, ParticipantDelIn, ParticipantOut
)
from ..service.meetings.participant import IParticipantService

logger = logging.getLogger(__name__)
router = APIRouter(prefix="/participants")


@router.post("/list", response_model=PageInationResult[ParticipantOut], summary="参会者列表")
@unified_resp
async def participant_list(list_in: ParticipantListIn, svc: IParticipantService = Depends()):
    return await svc.list(list_in)


@router.get("/detail", summary="参会者详情")
@unified_resp
async def participant_detail(detail_in: ParticipantDetailIn = Depends(), svc: IParticipantService = Depends()):
    return await svc.detail(detail_in.id)


@router.post("/add", summary="新增参会者")
@unified_resp
async def participant_add(add_in: ParticipantAddIn, svc: IParticipantService = Depends()):
    return await svc.add(add_in)


@router.post("/edit", summary="编辑参会者")
@unified_resp
async def participant_edit(edit_in: ParticipantEditIn, svc: IParticipantService = Depends()):
    return await svc.edit(edit_in)


@router.post("/del", summary="删除参会者")
@unified_resp
async def participant_del(del_in: ParticipantDelIn, svc: IParticipantService = Depends()):
    return await svc.delete(del_in.id)
